Skip to content

refactor: replace tidwall/jsonc with tailscale/hujson#679

Open
skevetter wants to merge 2 commits intomainfrom
sk/dep-replace-jsonc
Open

refactor: replace tidwall/jsonc with tailscale/hujson#679
skevetter wants to merge 2 commits intomainfrom
sk/dep-replace-jsonc

Conversation

@skevetter
Copy link
Copy Markdown
Owner

@skevetter skevetter commented Apr 4, 2026

Summary

tidwall/jsonc was used in pkg/devcontainer/config/parse.go to strip comments and trailing commas from devcontainer JSON files before unmarshalling. Replaces it with tailscale/hujson, which was already an indirect dependency and provides stricter, AST-based JSONC parsing.

The replacement adds proper error propagation: hujson.Standardize() returns an error on genuinely malformed input, whereas tidwall/jsonc silently passed malformed files through to json.Unmarshal. For all valid devcontainer.json files there is no behavior change.

Changes

  • pkg/devcontainer/config/parse.go: replaced jsonc.ToJSON(data) pattern with hujson.Standardize(data) (2 call sites), with error propagation
  • go.mod: tidwall/jsonc removed; tailscale/hujson promoted from indirect to direct
  • docs/pages/licenses/devpod.mdx: removed tidwall/jsonc entry, added tailscale/hujson (BSD-3-Clause)

Summary by CodeRabbit

Release Notes

  • Chores
    • Updated dependencies used for processing DevContainer configuration files.
    • Refreshed project license documentation.

Both packages strip JSON comments and trailing commas (JSONC format).
hujson was already an indirect dep in the module tree; promote it to a
direct dep and remove tidwall/jsonc entirely.

hujson.Standardize() returns an error on malformed input, which is now
propagated rather than silently ignored as before.
Remove stale github.com/tidwall/jsonc entry and add
github.com/tailscale/hujson (BSD-3-Clause) which replaced it.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 4, 2026

📝 Walkthrough

Walkthrough

The pull request replaces the github.com/tidwall/jsonc library with github.com/tailscale/hujson for JSON processing. Changes include updating Go module dependencies, documentation, and code implementation across three files to use the new library's API.

Changes

Cohort / File(s) Summary
Dependency Updates
go.mod, docs/pages/licenses/devpod.mdx
Replaced github.com/tidwall/jsonc (MIT) with github.com/tailscale/hujson (BSD-3-Clause) in both dependency declarations and license documentation. hujson moved from indirect to direct dependency.
Code Implementation
pkg/devcontainer/config/parse.go
Replaced jsonc.ToJSON(...) calls with hujson.Standardize(...) in ParseDevContainerFeature and ParseDevContainerJSONFile functions. Added explicit error handling for the normalization step before JSON unmarshalling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately and concisely summarizes the main change: replacing the tidwall/jsonc dependency with tailscale/hujson throughout the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sk/dep-replace-jsonc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added the size/s label Apr 4, 2026
@skevetter skevetter marked this pull request as ready for review April 6, 2026 06:06
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@go.mod`:
- Line 60: The go.mod currently pins github.com/tailscale/hujson to an old
pseudo-version (github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a);
update that require line to the newer pseudo-version (e.g.,
v0.0.0-20260302212456-ecc657c15afd) by running `go get
github.com/tailscale/hujson@latest` or replacing the version in the require
statement and then run `go mod tidy` to ensure module graph is updated; ensure
the updated module line referencing github.com/tailscale/hujson is the only
change and run tests/build to verify compatibility.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f7d3487b-6006-4a3f-89d9-0866c986280d

📥 Commits

Reviewing files that changed from the base of the PR and between 4a7835c and c0d9762.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • docs/pages/licenses/devpod.mdx
  • go.mod
  • pkg/devcontainer/config/parse.go

github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/stretchr/testify v1.11.1
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the latest commits on tailscale/hujson to see if there are newer versions
gh api repos/tailscale/hujson/commits --jq '.[0:5] | .[] | "\(.sha[0:12]) \(.commit.committer.date) \(.commit.message | split("\n")[0])"'

Repository: skevetter/devpod

Length of output: 220


🌐 Web query:

tailscale hujson releases latest commits 2024

💡 Result:

  • GitHub releases: tailscale/hujson has no releases published on GitHub. [1]
  • Latest commit in 2024: The repo shows one commit in 2024, on Oct 10, 2024: 29efb4a — “Add Value.All method to iterate over all values (#35)”. [2]
  • Go module versions (proxy-visible): Go Packages lists only two pseudo-versions for the module:
    • v0.0.0-20260302212456-ecc657c15afd (Mar 2, 2026)
    • v0.0.0-20210909182915-05264adefaff (Sep 9, 2021) [3]

Sources: [1] [2] [3]


🌐 Web query:

tailscale/hujson github repository

💡 Result:

The GitHub repository is:

https://github.com/tailscale/hujson

It’s the Go implementation of HuJSON (“JSON for Humans”), used by Tailscale for policy/ACL files. [1]

Source:
[1] (pkg.go.dev)

Citations:


Update hujson to a more recent version.

The dependency swap from github.com/tidwall/jsonc to github.com/tailscale/hujson is correct. However, the pinned version v0.0.0-20221223112325-20486734a56a (December 2022) is significantly outdated. The Go module proxy shows a much newer pseudo-version available: v0.0.0-20260302212456-ecc657c15afd (March 2026), with continued development activity as recently as October 2024. Update to the latest commit.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@go.mod` at line 60, The go.mod currently pins github.com/tailscale/hujson to
an old pseudo-version (github.com/tailscale/hujson
v0.0.0-20221223112325-20486734a56a); update that require line to the newer
pseudo-version (e.g., v0.0.0-20260302212456-ecc657c15afd) by running `go get
github.com/tailscale/hujson@latest` or replacing the version in the require
statement and then run `go mod tidy` to ensure module graph is updated; ensure
the updated module line referencing github.com/tailscale/hujson is the only
change and run tests/build to verify compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant